#include<iostream>
#include<queue>
#include<vector>
#include<list> 
#include <algorithm>
#include<map>
using namespace std;
class CQueue {
private:
    queue<int> library;
public:
	CQueue() {


    }

    void appendTail(int value) {
        library.push(value);
    }

	int deleteHead() {
		if (library.size())
		{
			int ret= library.front();
			library.pop();
			return ret;
		}
		else
		{
			return -1;
		}
	}
};


class Solution {
public:
	vector<int> topKFrequent(vector<int>& nums, int k) {
		map<int, int> temp0;
		for (auto item : nums)
		{
			temp0[item]++;
		}

		priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> mini_heap;
		for (auto item : temp0)
		{
			mini_heap.push({item.second,item.first});
			if (mini_heap.size() > k)
			{
				mini_heap.pop();
			}
		}

		vector<int> ret;
		while (!mini_heap.empty())
		{
			ret.push_back(mini_heap.top().second);
			mini_heap.pop();

		}
		return ret;




	}
};

int main()
{


	return 0;
}